VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmAPPurchaseInvoice 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   8970
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   11085
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   8970
   ScaleWidth      =   11085
   ShowInTaskbar   =   0   'False
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   29
      Top             =   8685
      Width           =   11085
      _ExtentX        =   19553
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   6326
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ITGTab SSTab1 
      Height          =   3290
      Left            =   0
      TabIndex        =   31
      Top             =   0
      Width           =   10755
      _ExtentX        =   18971
      _ExtentY        =   5794
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      InActiveTabForeColor=   -2147483639
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   16243138
      DisabledTabForeColor=   -2147483627
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   2970
         Left            =   -75000
         TabIndex        =   28
         Top             =   315
         Width           =   10755
         _ExtentX        =   18971
         _ExtentY        =   5239
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   5
         BeginProperty Column00 
            DataField       =   "cTranNo"
            Caption         =   "Transaction No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cCode"
            Caption         =   "Client ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               ColumnAllowSizing=   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1620.284
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   1425.26
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               Object.Visible         =   0   'False
               ColumnWidth     =   1530.142
            EndProperty
            BeginProperty Column03 
               Locked          =   -1  'True
               ColumnWidth     =   1470.047
            EndProperty
            BeginProperty Column04 
               Locked          =   -1  'True
               ColumnWidth     =   4229.858
            EndProperty
         EndProperty
      End
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   2970
         Left            =   0
         Top             =   315
         Width           =   10755
         _ExtentX        =   18971
         _ExtentY        =   5239
         FrameColor      =   4210752
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Receiving Report Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ThemeColor      =   5
         ColorFrom       =   16243138
         ColorTo         =   16250865
         Begin VB.ComboBox cboTaxType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmAPPurchaseInvoice.frx":0000
            Left            =   8300
            List            =   "frmAPPurchaseInvoice.frx":0007
            Style           =   2  'Dropdown List
            TabIndex        =   14
            Top             =   1530
            Width           =   1275
         End
         Begin VB.Timer Timer1 
            Interval        =   300
            Left            =   2565
            Top             =   495
         End
         Begin VB.CommandButton cmdPickCode 
            Height          =   300
            Left            =   2640
            Picture         =   "frmAPPurchaseInvoice.frx":000E
            Style           =   1  'Graphical
            TabIndex        =   4
            Top             =   870
            Width           =   315
         End
         Begin VB.CommandButton cmdPickPC 
            Height          =   300
            Left            =   2640
            Picture         =   "frmAPPurchaseInvoice.frx":0158
            Style           =   1  'Graphical
            TabIndex        =   9
            Top             =   1815
            Width           =   315
         End
         Begin VB.ComboBox cboTerms 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            Left            =   8300
            Style           =   2  'Dropdown List
            TabIndex        =   13
            Top             =   1180
            Width           =   1260
         End
         Begin ITGControls.ITGTextBox txtTranNo 
            Height          =   285
            Left            =   165
            TabIndex        =   0
            Top             =   555
            Width           =   2445
            _ExtentX        =   4101
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Transaction No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1135
            Required        =   -1  'True
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   5205
            TabIndex        =   1
            Tag             =   "Transaction Date"
            Top             =   555
            Width           =   1305
            _ExtentX        =   2302
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtName 
            Height          =   285
            Left            =   2955
            TabIndex        =   5
            TabStop         =   0   'False
            Top             =   870
            Width           =   3540
            _ExtentX        =   6138
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   3480
         End
         Begin ITGControls.ITGTextBox txtCode 
            Height          =   285
            Left            =   165
            TabIndex        =   3
            Top             =   870
            Width           =   2445
            _ExtentX        =   4101
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Supplier"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1135
            Required        =   -1  'True
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGTextBox txtPCDesc 
            Height          =   285
            Left            =   2955
            TabIndex        =   10
            TabStop         =   0   'False
            Top             =   1815
            Width           =   3545
            _ExtentX        =   6138
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   3480
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtPCCode 
            Height          =   285
            Left            =   165
            TabIndex        =   8
            Top             =   1815
            Width           =   2445
            _ExtentX        =   4101
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Profit Center"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1135
            Required        =   -1  'True
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtTaxType 
            Height          =   285
            Left            =   8300
            TabIndex        =   32
            Tag             =   "cboType"
            Top             =   1530
            Visible         =   0   'False
            Width           =   945
            _ExtentX        =   1561
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Transaction Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   885
         End
         Begin ITGControls.ITGTextBox txtTerms 
            Height          =   285
            Left            =   7005
            TabIndex        =   33
            Tag             =   "cboIntTerms"
            Top             =   1180
            Width           =   2415
            _ExtentX        =   4048
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Terms"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1105
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtEWTRate 
            Height          =   285
            Left            =   7020
            TabIndex        =   16
            Tag             =   "cboType"
            Top             =   2220
            Width           =   2550
            _ExtentX        =   4286
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "EWT Rate"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1240
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtAddress 
            Height          =   285
            Left            =   165
            TabIndex        =   6
            Top             =   1185
            Width           =   6330
            _ExtentX        =   10954
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Address"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   5020
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtContact 
            Height          =   285
            Left            =   165
            TabIndex        =   7
            Top             =   1500
            Width           =   6330
            _ExtentX        =   10954
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Contact"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   5020
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGDateBox dtpDateReceived 
            Height          =   285
            Left            =   8290
            TabIndex        =   2
            Tag             =   "Transaction Date"
            Top             =   555
            Width           =   1305
            _ExtentX        =   2302
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtReceivedBy 
            Height          =   285
            Left            =   165
            TabIndex        =   11
            Top             =   2130
            Width           =   6330
            _ExtentX        =   10954
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Received By"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   5020
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtInvNo 
            Height          =   285
            Left            =   7020
            TabIndex        =   12
            Top             =   870
            Width           =   2550
            _ExtentX        =   4286
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Supplier Invoice"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1240
            Required        =   -1  'True
            LinkForeColor   =   0
         End
         Begin VB.ComboBox cboTaxCode 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmAPPurchaseInvoice.frx":02A2
            Left            =   8300
            List            =   "frmAPPurchaseInvoice.frx":02A9
            Style           =   2  'Dropdown List
            TabIndex        =   15
            Top             =   1880
            Width           =   1275
         End
         Begin ITGControls.ITGTextBox txtTaxCode 
            Height          =   285
            Left            =   8370
            TabIndex        =   38
            Tag             =   "cboType"
            Top             =   1880
            Visible         =   0   'False
            Width           =   945
            _ExtentX        =   1561
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Transaction Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   885
         End
         Begin ITGControls.ITGTextBox txtTaxRate 
            Height          =   285
            Left            =   7020
            TabIndex        =   30
            Tag             =   "cboType"
            Top             =   2220
            Visible         =   0   'False
            Width           =   2550
            _ExtentX        =   4286
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Tax Rate"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1240
            Enabled         =   0   'False
            LinkForeColor   =   0
         End
         Begin VB.Label Label6 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Tax Code"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   7035
            TabIndex        =   37
            Top             =   1940
            Width           =   690
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Tax Type"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   7035
            TabIndex        =   36
            Top             =   1580
            Width           =   675
         End
         Begin VB.Label Label2 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Received Date"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   7070
            TabIndex        =   35
            Top             =   600
            Width           =   1050
         End
         Begin VB.Label Label1 
            BackStyle       =   0  'Transparent
            Caption         =   "Date"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   4035
            TabIndex        =   34
            Top             =   600
            Width           =   735
         End
      End
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   4725
      Left            =   0
      Top             =   3270
      Width           =   10755
      _ExtentX        =   18971
      _ExtentY        =   8334
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Details"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin VB.TextBox txtLongDesc 
         Appearance      =   0  'Flat
         DataField       =   "cLongDesc"
         Height          =   1215
         Left            =   2835
         MaxLength       =   1000
         MultiLine       =   -1  'True
         TabIndex        =   40
         Top             =   960
         Visible         =   0   'False
         Width           =   4065
      End
      Begin VB.ComboBox cboWRR 
         Height          =   315
         ItemData        =   "frmAPPurchaseInvoice.frx":02B0
         Left            =   150
         List            =   "frmAPPurchaseInvoice.frx":02BA
         Style           =   2  'Dropdown List
         TabIndex        =   39
         Top             =   1860
         Visible         =   0   'False
         Width           =   1035
      End
      Begin MSDataGridLib.DataGrid dtgWRR 
         CausesValidation=   0   'False
         Height          =   2580
         Left            =   0
         TabIndex        =   17
         Top             =   480
         Width           =   10755
         _ExtentX        =   18971
         _ExtentY        =   4551
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   10
         BeginProperty Column00 
            DataField       =   "cRefNo"
            Caption         =   "Reference No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cItemNo"
            Caption         =   "Product ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cDesc"
            Caption         =   "Description"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cWH"
            Caption         =   "Warehouse"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cUnit"
            Caption         =   "Unit"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "nQty"
            Caption         =   "Quantity"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "nPrice"
            Caption         =   "Price"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column07 
            DataField       =   "nAmount"
            Caption         =   "Amount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column08 
            DataField       =   "cBatchID"
            Caption         =   "Batch"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column09 
            DataField       =   "cBarcodeID"
            Caption         =   "Barcode ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Locked          =   -1  'True
               ColumnWidth     =   1154.835
            EndProperty
            BeginProperty Column01 
               Button          =   -1  'True
               ColumnWidth     =   1260.284
            EndProperty
            BeginProperty Column02 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   2445.166
            EndProperty
            BeginProperty Column03 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1349.858
            EndProperty
            BeginProperty Column04 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   780.095
            EndProperty
            BeginProperty Column05 
               Alignment       =   1
               ColumnWidth     =   854.929
            EndProperty
            BeginProperty Column06 
               Alignment       =   1
               ColumnWidth     =   1065.26
            EndProperty
            BeginProperty Column07 
               Alignment       =   1
               Locked          =   -1  'True
               ColumnWidth     =   1275.024
            EndProperty
            BeginProperty Column08 
               Button          =   -1  'True
               Object.Visible         =   0   'False
            EndProperty
            BeginProperty Column09 
               Object.Visible         =   0   'False
               ColumnWidth     =   884.976
            EndProperty
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtTaxableBase 
         Height          =   285
         Left            =   165
         TabIndex        =   19
         TabStop         =   0   'False
         Top             =   3795
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Taxable Base"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtEWT 
         Height          =   285
         Left            =   2790
         TabIndex        =   21
         TabStop         =   0   'False
         Top             =   4110
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "EWT"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtVat 
         Height          =   285
         Left            =   2790
         TabIndex        =   20
         TabStop         =   0   'False
         Top             =   3795
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "VAT"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtBalance 
         Height          =   285
         Left            =   7995
         TabIndex        =   27
         TabStop         =   0   'False
         Top             =   4110
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Balance"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtCredit 
         Height          =   285
         Left            =   7995
         TabIndex        =   26
         TabStop         =   0   'False
         Top             =   3795
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Credit"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtDebit 
         Height          =   285
         Left            =   7995
         TabIndex        =   25
         TabStop         =   0   'False
         Top             =   3480
         Width           =   2370
         _ExtentX        =   3969
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Debit"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1310
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtPayment 
         Height          =   285
         Left            =   5370
         TabIndex        =   24
         TabStop         =   0   'False
         Top             =   4110
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Payment"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtReturns 
         Height          =   285
         Left            =   5370
         TabIndex        =   23
         TabStop         =   0   'False
         Top             =   3795
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Returns"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
         Enabled         =   0   'False
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtGross 
         Height          =   285
         Left            =   5385
         TabIndex        =   22
         TabStop         =   0   'False
         Top             =   3480
         Width           =   2370
         _ExtentX        =   3969
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Label           =   "Gross"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   990
         TextBoxWidth    =   1320
         LinkForeColor   =   0
      End
      Begin ITGControls.ITGTextBox txtRemarks 
         Height          =   285
         Left            =   165
         TabIndex        =   18
         Top             =   3480
         Width           =   5010
         _ExtentX        =   8625
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Remarks"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   3950
         LinkForeColor   =   0
      End
   End
End
Attribute VB_Name = "frmAPPurchaseInvoice"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.05

Option Explicit

'Object variables
Private oPrint As New clsPrinting

'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset

'ADO Connection variables

Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection

'Form mode enumeration
Enum eBasicPIMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As eBasicPIMode

'Other declarations
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

Private lSystemGenerated As Boolean
Public strNo As String

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Public lAllowCost As Boolean

Private Sub cboTaxType_Click()
    txtTaxType = Trim(cboTaxType)
End Sub

Private Sub cboTaxType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub cboTaxCode_Click()
    txtTaxCode = Trim(cboTaxCode)
    If Trim(cboTaxType) <> "" Then
        txtEWTRate = GetValueFrTable("cValue", "PARAMETER_USER", "cParamName = '" & Trim(cboTaxCode) & "' and cCompanyID = '" & Trim(COID) & "' and cType = 'ATCCode'")
    End If
End Sub

Private Sub cboTaxCode_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub dtgWRR_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)
If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 5
            If rsDetail!lOtherItem Then Exit Sub
            
            Set rs = Nothing
                
            sSQL = "SELECT (nQty - ISNULL(nReceived,0)) AS nQty, B.nQty as nOrig FROM PO_T B " & _
                "LEFT OUTER JOIN V_ReceivedOrder A ON B.nIdentity = A.nRefIdentity AND B.cItemNo = A.cItemNo " & _
                "WHERE B.cPONo = '" & Trim(rsDetail!cRefNo) & "' AND B.cCompanyID = '" & COID & "' "
            rs.Open sSQL, cn, adOpenKeyset, adLockReadOnly
            
            If CDbl(dtgWRR.Columns(5).Value) > CDbl(rs!nQty) Then
                If MsgBox("You're going to change quantity " & vbCr & "which is greater than to the PO available quantity." & vbCr & vbCr & _
                        "PO quantity: " & Trim(rs!nOrig) & vbCr & "Available: " & Trim(rs!nQty), vbQuestion + vbYesNo, msgTtl) = vbYes Then
                    Cancel = False
                Else
                    Cancel = True
                End If
            End If
    End Select
    
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

Private Sub txtTaxType_Change()
    If Trim(txtTaxType) <> "" Or txtTaxType <> vbNullString Then
        cboTaxType = Trim$(txtTaxType)
    Else: cboTaxType.ListIndex = -1
    End If
End Sub

Private Sub txtTaxCode_Change()
    If Trim(txtTaxCode) <> "" Or txtTaxCode <> vbNullString Then
        cboTaxCode = Trim$(txtTaxCode)
    Else: cboTaxCode.ListIndex = -1
    End If
End Sub

Private Sub cboTerms_Click()
    txtTerms = Trim(cboTerms)
End Sub

Private Sub cboTerms_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub txtTerms_Change()
    If Trim(txtTerms) <> "" Or txtTerms <> vbNullString Then
        cboTerms = Trim$(txtTerms)
    Else: cboTerms.ListIndex = -1
    End If
End Sub

Private Sub cboWRR_Click()
    If dtgWRR.Col = 3 Then
        rsDetail!cWH = cboWRR
    ElseIf dtgWRR.Col = 4 Then
        rsDetail!cUnit = cboWRR
        rsDetail!nFactor = GetValueFrTable("nFactor", "Item_Unit", "cUnit = '" & Trim(rsDetail!cUnit) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
    End If
End Sub

Private Sub cboWRR_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgWRR.Col = 3 Then
            rsDetail!cWH = cboWRR
            cboWRR.Visible = False
            dtgWRR.Col = 4
            dtgWRR.SetFocus
        ElseIf dtgWRR.Col = 4 Then
            rsDetail!cUnit = cboWRR
            rsDetail!nFactor = GetValueFrTable("nFactor", "Item_Unit", "cUnit = '" & Trim(rsDetail!cUnit) & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
            dtgWRR.Col = 5
            dtgWRR.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboWRR.Visible = False
    End If
End Sub

Private Sub cboWRR_LostFocus()
    cboWRR.Visible = False
End Sub

Private Sub cmdPickCode_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtCode)
    frmITGPicker.zType = QSupplier
    frmITGPicker.Show vbModal
    txtCode = frmITGPicker.zCode
    txtName = frmITGPicker.zName
    If Trim(txtName) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub cmdPickPC_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtPCCode)
    frmITGPicker.zType = QProfitCenter
    frmITGPicker.Show vbModal
    txtPCCode = frmITGPicker.zCode
    txtPCDesc = frmITGPicker.zName
    If Trim(txtPCDesc) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

Private Sub dtgWRR_AfterColUpdate(ByVal ColIndex As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 1
            If GetValueFrTable("cItemNo", "ITEM", "cItemNo = '" & Trim(dtgWRR.Columns(1).Value) & "'") <> "" Then
                GetInitialItemValues rsDetail
                dtgWRR.Col = 5
                dtgWRR.Columns(5).Value = IIf(IsNull(rsDetail!nQty), 0, rsDetail!nQty)
            End If
        Case 5
            ComputeAmount
            ComputeTotal
        Case 6
            ComputeAmount
            ComputeTotal
            If IsNull(rsDetail!nRefIdentity) Or rsDetail!nRefIdentity = "" Then Exit Sub
            If GetValueFrTable("nPrice", "PO_T", "nIdentity = " & rsDetail!nRefIdentity & "") < rsDetail!nPrice Then
                MsgBox "Price must not exceed purchase order price.", vbExclamation + vbInformation, msgTtl
                dtgWRR.Col = 6
                dtgWRR.SetFocus
                Exit Sub
            End If
    End Select
    
End Sub

Private Sub dtgWRR_ButtonClick(ByVal ColIndex As Integer)
'Added 8-29-2007
If ColIndex = 2 Then
    If Mode <> Find Then
        Call MoveText(txtLongDesc, dtgWRR, dtgWRR.Columns(2))
        txtLongDesc = rsDetail!cLongDesc & ""
    End If
End If

If Mode = AddNewEdit Then 'Exit Sub
    Select Case ColIndex
        Case 1
            If lPickListActive Then Exit Sub
            If rsDetail!cType = "Trade" Then
                If Not rsDetail!lOtherItem Then Exit Sub
                If lPickListActive Then Exit Sub
                sFilterString = Trim(dtgWRR.Columns(1).Text)
                frmITGPicker.zType = QProduct
                frmITGPicker.Show vbModal
                dtgWRR.Columns(1).Value = Trim(frmITGPicker.zCode) & ""
                If (Trim(frmITGPicker.zName) & "") <> "" Then
                    GetInitialItemValues rsDetail
                    dtgWRR.Col = 5
                    dtgWRR.Columns(5).Value = 0
                End If
            ElseIf rsDetail!cType = "Asset" Then
                If lPickListActive Then Exit Sub
                sFilterString = Trim(dtgWRR.Columns(1).Text)
                frmITGPicker.zType = QFixedAsset
                frmITGPicker.Show vbModal
                dtgWRR.Columns(1).Value = Trim(frmITGPicker.zCode) & ""
                If (Trim(frmITGPicker.zName) & "") <> "" Then
                    dtgWRR.Columns(2).Value = Trim(GetValueFrTable("cDesc", "ASSET", "cAssetNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
                    SendKeys "{tab}"
                    SendKeys "{tab}"
                End If
            End If
            
        Case 3
            Call LoadComboValues(cboWRR, "cWH", "WHSE", "WHERE cCompanyID = '" & COID & "'")
            Call MoveCombo(cboWRR, dtgWRR, dtgWRR.Columns(3))
            ComboLoadValue cboWRR, Trim(dtgWRR.Columns(3).Text)
        Case 4
            Call LoadComboValues(cboWRR, "cUnit", "Item_Unit", "WHERE cCompanyID = '" & COID & "' and cItemNo = '" & Trim(rsDetail!cItemNo) & "' ")
            Call MoveCombo(cboWRR, dtgWRR, dtgWRR.Columns(4))
            ComboLoadValue cboWRR, Trim(dtgWRR.Columns(4).Text)
        Case 8
            RepName = Trim(dtgWRR.Columns(1).Text)
            frmFindBatch.mBatchPick = Batch_Lot
            frmFindBatch.Show vbModal
            dtgWRR.Columns(8).Value = frmFindBatch.mBatchID
    End Select
Else
    Select Case ColIndex
        Case 1
            If Mode <> Find Then
                If Trim(dtgWRR.Columns(1).Text) <> "" Then
                End If
            End If
    End Select
End If
End Sub

'Set the datagrid as active control
Private Sub dtgWRR_Click()
    If Mode = AddNewEdit Then dtgName = dtgWRR.Name
End Sub

Private Sub dtgWRR_Error(ByVal DataError As Integer, Response As Integer)
    Response = 0
End Sub

Private Sub dtgWRR_GotFocus()
    dtgName = dtgWRR.Name
End Sub

Private Sub dtgWRR_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgWRR_KeyPress(KeyAscii As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
    
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgWRR.Col
            Case 1
                If GetValueFrTable("cItemNo", "ITEM", "cItemNo = '" & Trim(dtgWRR.Columns(1).Value) & "'") = "" Then
                    dtgWRR_ButtonClick (1) 'use button click
                End If
            Case 3
                If Not cboWRR.Visible Then dtgWRR_ButtonClick (3)
            Case 8
                TBNewLine
                dtgWRR.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else: KeyAscii = Asc(UCase(Chr(KeyAscii)))        'All Upper Case String
    End If

End Sub

'Right click menu popup
Private Sub dtgWRR_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgWRR.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

'Set Your Object
Private Sub Form_Load()
    Set FrmName = Me
    FormSetup
    
    If Not lAllowCost Then
        AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'MI04'")
    Else: AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'MI03'")
    End If
    
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    
       
    Set FrmName = Me
    FormLocking True
    FormSearch True
    SearchObj True

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    
    Call LoadComboValues(cboTerms, "cParamName", "PARAMETER_USER", "WHERE cType = 'TERMS' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    Call LoadComboValues(cboTaxCode, "cParamName", "PARAMETER_USER", "WHERE cType = 'ATCCode' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    Call LoadComboValues(cboTaxType, "cParamName", "PARAMETER_USER", "WHERE cType = 'TAXTYPE' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
    
    Call ColumnVisible("Barcode ID", dtgWRR)
    
    Mode = Find
    txtTranNo.Locked = False
    

    
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False

    Set oPrint = Nothing
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing

    Set frmBasicMIWRR = Nothing

    lCloseWindow = True
    
    'oForm(Me.Tag).Mode = 1
    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Add new record to the recordset
Public Sub TBNew()

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtTranNo.BackColor = &HE0FFFF
    Mode = AddNewEdit

    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connHeader
        OpenNewConnection connDetail
        OpenRecordsetWithCN rsDetail, "*", "purchase_t", connDetail, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "purchase", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else: vBM = rsHeader.Bookmark
    End If

    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    
    txtReturns = "0.00"
    txtCredit = "0.00"
    txtDebit = "0.00"
    txtPayment = "0.00"
    txtBalance = "0.00"
    
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    SSTab1.ActiveTab = 0
    txtTranNo.SetFocus

    'System generated number
    lSystemGenerated = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTO_NUMBER_WRR' ")
    If lSystemGenerated Then rsHeader!cTranNo = GetAutoCtrlNo(rsHeader, "AUTO_NUMBER_WRR", "Purchase", "cTranNo")
    
    
    
End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    
    If rsHeader.Status = adRecNew Then TBUndoCurrent
    
    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll
    
    UnbindControls
    
    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM
    
    Set FrmName = Me
    FormLocking True
    
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, True
    Else
        RSZero
        Mode = Find
    End If

    sbRS.Panels(2) = ""
    
    SetDataSource
    SetDataField

ErrorHandler:

    cboWRR.Visible = False

    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If
   
    If rsHeader.RecordCount = 0 Then RSZero
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then lBoolean = True
    
    If Not MandatoryOK Then Exit Sub
    
    'System generated number
    If rsHeader.Status = adRecNew Then
    

    
        If lSystemGenerated Then
            If ChkCtrlNo(rsHeader, "AUTO_NUMBER_WRR", "Purchase", "cTranNo", rsHeader!cTranNo) <> rsHeader!cTranNo Then
                GetChild
                
                rsHeader!cTranNo = strNo
                
                If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
                Do Until rsDetail.EOF
                    rsDetail!cTranNo = strNo
                    rsDetail.MoveNext
                Loop
                
                GetChild
            End If
        End If
    End If
    
    OKUpdate = False
    cn.BeginTrans
    
    connHeader.BeginTrans
    connDetail.BeginTrans
    
    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
    
    cn.CommitTrans
    connHeader.CommitTrans
    connDetail.CommitTrans
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, True
    Mode = Normal
        
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    
    'Audit trail
    UpdateLogFile "Purchase", Trim(txtTranNo), IIf(lBoolean, "Inserted", "Updated")

    'Update GL Activity
    UpdateGLA "Update", "PI", Trim(txtTranNo)
    
    'update system generated number
    If lBoolean Then
        If lSystemGenerated And strNo = rsHeader!cTranNo Then UpdateControlNo strNo, rsHeader!cTranNo, "AUTO_NUMBER_WRR"
    End If
    
    MsgBox "Record/s successfully saved.", vbInformation, msgTtl
    sbRS.Panels(2) = ""
    
ErrHandler:

    cboWRR.Visible = False

    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, msgTtl
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, msgTtl
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Edit is not allowed.", vbExclamation, msgTtl
        Exit Sub
    End If
    If Not AllowEdit Then Exit Sub
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    txtTranNo.Locked = True
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark

    txtCode.Locked = True
    cmdPickCode.Enabled = False
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler

    sID = Trim(txtTranNo)
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Deletion is not allowed.", vbExclamation, msgTtl
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, msgTtl) = vbNo Then Exit Sub

    If Not AllowDelete("delete") Then Exit Sub

    cn.Execute ("UPDATE SO_T SET lDRReady = 0, cRefNo = NULL WHERE cRefNo = '" & Trim(txtTranNo) & "'")
    cn.Execute ("UPDATE PRODUCTION_BM SET lDRReady = 0, cTranNo = NULL WHERE cTranNo = '" & Trim(txtTranNo) & "'")
    
    'Update GL Activity
    UpdateGLA "Delete", "Transaction", Trim(txtTranNo)
    
    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    
    'Audit trail
    UpdateLogFile "Transaction", Trim(txtTranNo), "Deleted"

    rsHeader.Delete adAffectCurrent
    
    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    

    
    TBPrevRec

    Mode = Normal

    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE Purchase_T WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE Purchase WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtTranNo.Locked = True
    frmITGSearch.Show 'vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."
        
    OpenNewConnection connHeader
    OpenNewConnection connDetail
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
            
    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtTranNo.Locked = False
        txtTranNo.SetFocus
        Exit Sub
    End If
    
    OpenRecordsetWithCN rsHeader, "*", "Purchase", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
                   
    OpenRecordsetWithCN rsDetail, "*", "Purchase_T", connDetail, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM Purchase WHERE " & sTemp & ")")
         
    Set FrmName = Me
    FormLocking True

    If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtTranNo.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find
    

    
End If

End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgWRR.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader
    

End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader
    

End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader
    

End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader
    

End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()
    ReferenceListing
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler
    
    If dtgName = dtgWRR.Name Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgWRR.Bookmark
        GetChild
        dtgWRR.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
        ComputeTotal
    End If
    GetChild

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    MsgBox "Unavailable on " & Me.Name

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Cancel current record
Public Sub TBCancelRecord()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled.", vbExclamation, msgTtl
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, msgTtl) = vbNo Then Exit Sub

    'Audit trail
    UpdateLogFile "Transaction", Trim(txtTranNo), "Cancelled"

    cn.Execute ("UPDATE Purchase SET lCancelled = 1 WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'")
    
    sbRS.Panels(5) = "CANCELLED"
    Mode = Normal
    
    rsHeader!lCancelled = True
    rsHeader.UpdateBatch adAffectAll

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Print
Public Sub TBPrintRecord()
    cModule = "Purchase_Invoice"
    oPrint.PrintReceipt Trim(txtTranNo)
End Sub

Public Sub TBAccountAffected()
    RepName = "Transaction"
    frmAccountAffected.mModuleType = KPI
    frmAccountAffected.mRefPK = txtTranNo.Text
    frmAccountAffected.Show vbModal
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgWRR.DataSource = rsDetail
    Set txtLongDesc.DataSource = rsDetail
    
End Sub

'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        txtTranNo.DataField = !cTranNo
        dtbDate.DataField = !dDate
        txtCode.DataField = !cCode
        txtPCCode.DataField = !cPCCode
        txtRemarks.DataField = !cRemarks
        txtGross.DataField = !nGross
        txtTaxType.DataField = !cTaxType
        txtTaxCode.DataField = !nTaxcode
        txtTerms.DataField = !cTerms
        txtName.DataField = !cName
        txtAddress.DataField = !cAddress
        txtContact.DataField = !cContact
        txtReceivedBy.DataField = !cReceivedBy
        dtpDateReceived.DataField = !dReceived
        txtEWTRate.DataField = !nEWTRATE
        txtInvNo.DataField = !cSuppInvNo
        txtVat.DataField = !nVAT
        txtEWT.DataField = !nEWT
        txtTaxableBase.DataField = !nTaxableBase
    End With
End Sub

Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler

    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount

        If rsHeader.Status <> adRecNew Then
            txtTranNo.Locked = True
        Else
            txtTranNo.Locked = False
        End If

        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else: sbRS.Panels(2) = ""
        End If
        
        GetChild
        ShowTranBalance
        
        If rsHeader!lCancelled = True Then
            sbRS.Panels(5) = "CANCELLED"
        Else: sbRS.Panels(5) = ""
        End If
    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtTranNo.Locked = False
    End If

    If Mode = AddNewEdit Then
        dtgWRR.Refresh
    End If

ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Show the balances of each sales invoice
'Binding of the textboxex was disabled
Private Sub ShowTranBalance()
Dim rsBalance As New Recordset

    If Mode = AddNewEdit Then Exit Sub
    sSQL = "exec sp_PIBalanceInquiry '" & rsHeader!cTranNo & "','" & COID & "'"
    rsBalance.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
    
    txtDebit = 0
    txtCredit = 0
    txtReturns = 0
    txtPayment = 0
    txtBalance = 0
    
    If rsBalance.RecordCount <> 0 Then
        txtDebit = rsBalance!nDebit
        txtCredit = rsBalance!nCredit
        txtReturns = rsBalance!nReturns
        txtPayment = rsBalance!nPaid
        txtBalance = rsBalance!nBalance
    End If
    Set rsBalance = Nothing
End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab1.TabEnabled(1) = False
    Else
        SSTab1.TabEnabled(1) = True
    End If
End Sub
Private Sub txtLongDesc_KeyPress(KeyAscii As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Sub txtLongDesc_LostFocus()
    txtLongDesc.Visible = False
    dtgWRR.Col = 2
    dtgWRR.SetFocus
End Sub
Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_SUPPLIER", "cCode = '" & Trim(txtCode) & "'")
    
    If Mode = AddNewEdit Then
        rsHeader!cTerms = GetValueFrTable("cTerm", "CLIENT_SUPPLIER", "cCode = '" & Trim(txtCode) & "'")
        rsHeader!cAddress = GetAddress("CLIENT_SUPPLIER", "cCode = '" & Trim(txtCode) & "'") & ""
    End If
    
End Sub

Private Sub txtCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtName) = "" And Trim(txtCode) <> "" Then cmdPickCode_Click
End Sub

Private Sub txtPCCode_Change()
    txtPCDesc = ""
    txtPCDesc = GetValueFrTable("cDescription", "PROFITCENTER", "cPCCode = '" & Trim(txtPCCode) & "'")
End Sub

Private Sub txtPCCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtPCDesc) = "" And Trim(txtPCCode) <> "" Then cmdPickPC_Click
End Sub

Private Sub txtTaxRate_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then TBNewLine
End Sub

Private Sub txtTranNo_LostFocus()
    'Does Code Already Exist
    If Mode = AddNewEdit Then
        If Trim(txtTranNo) = "" Then
            MsgBox "Empty primary input.", vbInformation, msgTtl
            If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
            txtTranNo.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtTranNo = Trim(txtTranNo)
            If IDExisting(rsHeader, "cTranNo", "Purchase", Trim(rsHeader!cTranNo)) Then
                MsgBox "Transaction No. already exist.", vbInformation, msgTtl
                If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
                txtTranNo.SetFocus
            End If
        End If
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean

    MandatoryOK = True

    If Trim(txtTranNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Number' is mandatory. Null value is not allowed.", vbInformation, msgTtl
        txtTranNo.SetFocus
        Exit Function
    End If
    
    ComputeAmount
    ComputeTotal
    
    If rsHeader.Status = adRecNew And lSystemGenerated = False Then
        If IDExisting(rsHeader, "cTranNo", "Purchase", Trim(rsHeader!cTranNo)) Then
            MandatoryOK = False
            MsgBox "Transaction No. already exist.", vbInformation, msgTtl
            txtTranNo.SetFocus
            Exit Function
        End If
    End If

    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, msgTtl
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtTerms) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Terms' is mandatory. Null value is not allowed.", vbInformation, msgTtl
        cboTerms.SetFocus
        Exit Function
    ElseIf Trim(txtCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Supplier' is mandatory. Null value is not allowed.", vbInformation, msgTtl
        txtCode.SetFocus
        Exit Function
    End If
    
    GetChild
    
    'Transaction without details
    If rsDetail.RecordCount = 0 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, msgTtl
        dtgWRR.SetFocus
        Exit Function
    End If
    
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cItemNo) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cItemNo) = "" Then
                rsDetail.Delete
            Else: rsDetail.MoveNext
            End If
        Else: rsDetail.MoveNext
        End If
    Loop

    GetChild

    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, msgTtl
        MandatoryOK = False
        Exit Function
    End If

End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
On Error Resume Next
    rsDetail.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
End Sub

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""
    
    Set dtgWRR.DataSource = Nothing
    dtgWRR.Refresh
    
    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    
    txtTranNo.Locked = False
    txtTranNo.SetFocus
    
    Mode = Find
    
End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cmdPickCode.Enabled = lEnable
    cboTaxType.Enabled = lEnable
    cboTerms.Enabled = lEnable
End Sub

'Gets initital item values
Private Sub GetInitialItemValues(RefRS As Recordset)
    RefRS!cDesc = Trim(GetValueFrTable("cDesc", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
    RefRS!cUnit = Trim(GetValueFrTable("cUnit", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
    RefRS!cWH = Trim(GetValueFrTable("cWH", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
    RefRS!nPrice = Trim(GetValueFrTable("nSRPrice", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'")) & ""
    RefRS!nCost = IIf(GetValueFrTable("nAveCost", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'") = "", 0, GetValueFrTable("nAveCost", "ITEM", "cItemNo = '" & Trim(RefRS!cItemNo) & "'"))
    RefRS!nQty = 0
End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True
    
    If Trim$(txtTranNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTranNo LIKE '" & Trim$(txtTranNo.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If
    
    If Trim$(txtCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cCode LIKE '" & Trim$(txtCode.Text) & "%'"
    End If
    
    If Trim$(txtTerms.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTerms LIKE '" & Trim$(txtTerms.Text) & "%'"
    End If
    
    If Trim$(txtTaxType.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTaxType LIKE '" & Trim$(txtTaxType.Text) & "%'"
    End If
    
    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function

'Form list to grid
Public Sub AddDetailsFromList()
    
    GetChild
    
    With frmRefList.lvwList
        For i = 1 To .ListItems.Count
            If .ListItems(i).Checked = True Then
                rsDetail.AddNew
                rsDetail!cCompanyID = COID
                rsDetail!cTranNo = Trim(rsHeader!cTranNo)
                rsDetail!cRefNo = Trim(frmRefList.mRefPK)
                rsDetail!cItemNo = IIf((Trim(.ListItems(i).Text) = "Other Item"), "", Trim(.ListItems(i).Text)) & "" 'Trim(.ListItems(i).Text)
                rsDetail!cDesc = Trim(.ListItems(i).SubItems(1))
                rsDetail!cWH = Trim(GetValueFrTable("cWH", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
                rsDetail!cUnit = Trim(.ListItems(i).SubItems(3))
                rsDetail!nQty = CDbl(.ListItems(i).SubItems(4))
                rsDetail!nPrice = CDbl(.ListItems(i).SubItems(5))
                rsDetail!nAmount = CDbl(.ListItems(i).SubItems(6))
                rsDetail!nRefIdentity = CDbl(.ListItems(i).SubItems(7))
                rsDetail!nFactor = CDbl(IIf(.ListItems(i).SubItems(8) = "", 0, .ListItems(i).SubItems(8)))
                
                rsDetail!lOtherItem = IIf((Trim(.ListItems(i).Text) = "Other Item"), True, False)
                If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = True Then
                    rsDetail!cBarcodeID = CDbl(.ListItems(i).SubItems(12))
                End If
            End If
        Next i
    End With

    GetChild
    
    ComputeAmount
    ComputeTotal

End Sub

'Form list to grid
Public Sub AddDetailsFromList_PullOut()
    
    GetChild
    
    rsDetail.CancelBatch adAffectAll 'DeleteAllDetails
    
    With frmARDRList.lvwList
        For i = 1 To .ListItems.Count
            If .ListItems(i).Checked = True Then
                rsHeader!cPullOutNo = Trim(frmARDRList.mRefPK)
                rsDetail.AddNew
                rsDetail!cCompanyID = COID
                rsDetail!cTranNo = Trim(rsHeader!cTranNo)
                rsDetail!cRefNo = Trim(.ListItems(i).SubItems(8))
                rsDetail!cItemNo = IIf((Trim(.ListItems(i).Text) = "Other Item"), "", Trim(.ListItems(i).Text)) & "" 'Trim(.ListItems(i).Text)
                rsDetail!cDesc = Trim(.ListItems(i).SubItems(1))
                rsDetail!cWH = Trim(GetValueFrTable("cWH", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
                rsDetail!cUnit = Trim(.ListItems(i).SubItems(3))
                rsDetail!nQty = CDbl(.ListItems(i).SubItems(4))
                rsDetail!nPrice = CDbl(.ListItems(i).SubItems(5))
                rsDetail!nAmount = CDbl(.ListItems(i).SubItems(6))
                rsDetail!nRefIdentity = CDbl(.ListItems(i).SubItems(7))
                rsDetail!nCost = GetValueFrTable("nAveCost", "ITEM", "cItemNo = '" & Trim(rsDetail!cItemNo) & "'")
            End If
        Next i
    End With

    GetChild
    
    ComputeAmount
    ComputeTotal

End Sub

'Computes total amount per detail line
Private Sub ComputeAmount()
On Error Resume Next
Dim nAmount As Double
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
    With dtgWRR
        nAmount = IIf(IsNull(.Columns(5).Value), 0, .Columns(5).Value) * _
                    IIf(IsNull(.Columns(6).Value), 0, .Columns(6).Value)
        .Columns(7).Text = Format(nAmount, "###,##0.#0")
        rsDetail!nCost = rsDetail!nPrice
    End With
End Sub

'Gross amount
Public Sub ComputeTotal()
Dim n As Double
    
On Error Resume Next
    
    If Mode <> AddNewEdit Then Exit Sub
    
     n = 0
    Set rs = New Recordset
    Set rs = rsDetail.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"

    rs.MoveFirst
    Do Until rs.EOF
        n = n + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        rs.MoveNext
    Loop
    Set rs = Nothing
    
    If Trim(rsHeader!cTaxType) = "VAT" Then
        rsHeader!nTaxableBase = (n / getTax)
        rsHeader!nEWT = rsHeader!nTaxableBase * rsHeader!nEWTRATE
        rsHeader!nVAT = n - rsHeader!nTaxableBase
    Else
        rsHeader!nVAT = 0
        rsHeader!nTaxableBase = 0
        rsHeader!nEWT = 0
    End If
        rsHeader!nGross = n
        txtBalance = n - txtDebit + txtCredit - txtPayment
    
    
End Sub

'Reference listing
Sub ReferenceListing()
On Error Resume Next
    
    If Trim(txtName) = "" Then
        MsgBox "Please pick client.", vbExclamation, msgTtl
        Exit Sub
    End If
    
    RepName = Trim(txtCode)
    If Not lAllowCost Then cString = "NOCOST"
    sCondition = "'" & COID & "', '" & Trim(txtCode) & "', ' '"
    frmRefList.mType = PurchaseInv 'WRR_Purchase
        
    If Not frmRefList.Visible Then frmRefList.Show vbModal
    
End Sub

'Update reference number in SO_T table (Buy-out & No Stock)
Sub Update_SO_T_RefNo(TranNo As String)
Dim RefPONo As String
Dim rsUSO_TRN As New Recordset
    
    cn.Execute ("UPDATE SO_T SET lDRReady = 0, cRefNo = NULL WHERE cRefNo = '" & Trim(TranNo) & "' AND cCompanyID = '" & COID & "'")
    cn.Execute ("UPDATE PRODUCTION_BM SET lDRReady = 0, cTranNo = NULL WHERE cTranNo = '" & Trim(TranNo) & "' AND cCompanyID = '" & COID & "'")
    
    GetChild
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        RefPONo = rsDetail!cRefNo
    
        'For SO ------------------------------------------------------------------------------------------------------------------------------------
        sSQL = "SELECT A.cSONo, A.nIdentity, A.cItemNo FROM SO_T A " & _
                "LEFT OUTER JOIN REQUISITION B ON A.cCompanyID = B.cCompanyID AND A.cSONo = B.cRefNo " & _
                "LEFT OUTER JOIN REQUISITION_T C ON B.cPRNo = C.cPRNo AND A.cCompanyID = C.cCompanyID AND A.nIdentity = C.nRefIdentity " & _
                "LEFT OUTER JOIN PO_T D ON A.cCompanyID = D.cCompanyID AND B.cPRNo = D.cPRNo AND C.nIdentity = D.nPRIdentity " & _
                "WHERE B.cType = 'From SO' AND A.cStatus IN ('Buy-out', 'No Stock') " & _
                "AND D.cPONo = '" & Trim(RefPONo) & "' AND A.cCompanyID = '" & COID & "'"
                
        rsUSO_TRN.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        Do Until rsUSO_TRN.EOF
            cn.Execute "UPDATE SO_T SET cRefNo = '" & Trim(TranNo) & "', lDRReady = 1 WHERE cSONo = '" & Trim(rsUSO_TRN!cSONO) & "' AND " & _
                        "nIdentity = '" & rsUSO_TRN!nIdentity & "' AND cItemNo = '" & Trim(rsUSO_TRN!cItemNo) & "' AND cCompanyID = '" & COID & "'"
            rsUSO_TRN.MoveNext
        Loop
        
        rsUSO_TRN.Close
        '-------------------------------------------------------------------------------------------------------------------------------------------
        
        'For Production Order ----------------------------------------------------------------------------------------------------------------------
        sSQL = "SELECT A.cTranNo, A.nIdentity, A.cItemNo " & _
                "FROM PRODUCTION_BM A LEFT OUTER JOIN REQUISITION B ON A.cCompanyID = B.cCompanyID AND A.cTranNo = B.cRefNo " & _
                "LEFT OUTER JOIN REQUISITION_T C ON B.cPRNo = C.cPRNo AND A.cCompanyID = C.cCompanyID AND A.nIdentity = C.nRefIdentity " & _
                "LEFT OUTER JOIN PO_T D ON A.cCompanyID = D.cCompanyID AND B.cPRNo = D.cPRNo AND C.nIdentity = D.nPRIdentity " & _
                "WHERE B.cType = 'Production' AND A.cStatus IN ('Buy-out', 'No Stock') AND D.cPONo = '" & Trim(RefPONo) & "' AND A.cCompanyID = '" & COID & "'"
                
        rsUSO_TRN.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        Do Until rsUSO_TRN.EOF
            cn.Execute "UPDATE PRODUCTION_BM SET cTranNo = '" & Trim(TranNo) & "', lDRReady = 1 WHERE cTranNo = '" & Trim(rsUSO_TRN!cTranNo) & "' AND " & _
                        "nIdentity = '" & rsUSO_TRN!nIdentity & "' AND cItemNo = '" & Trim(rsUSO_TRN!cItemNo) & "' AND cCompanyID = '" & COID & "'"
            rsUSO_TRN.MoveNext
        Loop
        
        rsUSO_TRN.Close
        '-------------------------------------------------------------------------------------------------------------------------------------------
        
        rsDetail.MoveNext
    Loop
    
    Set rsUSO_TRN = Nothing

End Sub

'Update reference number in SO_T table (Production)
Sub Update_SO_T_RefNo_Prod(TranNo As String)
Dim RefPONo As String
Dim rsUSO_TRNP As New Recordset
    
    cn.Execute ("UPDATE SO_T SET lDRReady = 0, cRefNo = NULL WHERE cRefNo = '" & Trim(TranNo) & "' AND cCompanyID = '" & COID & "'")
    
    GetChild
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        RefPONo = rsDetail!cRefNo
           
        'For SO ------------------------------------------------------------------------------------------------------------------------------------
        sSQL = "SELECT A.cSONo, A.nIdentity, A.cItemNo " & _
                "FROM SO_T A LEFT OUTER JOIN PRODUCTION B ON A.cCompanyID = B.cCompanyID AND A.cSONo = B.cRefNo " & _
                "LEFT OUTER JOIN PRODUCTION_FG C ON B.cTranNo = C.cTranNo AND A.cCompanyID = C.cCompanyID AND A.nIdentity = C.nRefIdentity  " & _
                "WHERE B.cType = 'From SO' AND A.cStatus IN ('Production') AND B.cTranNo = '" & Trim(RefPONo) & "' AND A.cCompanyID = '" & COID & "'"
                
        rsUSO_TRNP.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        Do Until rsUSO_TRNP.EOF
            cn.Execute "UPDATE SO_T SET cRefNo = '" & Trim(TranNo) & "', lDRReady = 1 WHERE cSONo = '" & Trim(rsUSO_TRNP!cSONO) & "' AND " & _
                        "nIdentity = '" & rsUSO_TRNP!nIdentity & "' AND cItemNo = '" & Trim(rsUSO_TRNP!cItemNo) & "' AND cCompanyID = '" & COID & "'"
            rsUSO_TRNP.MoveNext
        Loop
        
        rsUSO_TRNP.Close
        '-------------------------------------------------------------------------------------------------------------------------------------------
        
        rsDetail.MoveNext
    Loop
    
    Set rsUSO_TRNP = Nothing

End Sub

Sub EditDetail(bval As Boolean)
    dtgWRR.Columns(1).Locked = Not bval
    dtgWRR.Columns(5).Locked = Not bval
End Sub

'Update reference number in REQUISITIONSLIP_T table (No Stock)
Sub Update_RS_RefNo(TranNo As String)
Dim RefPONo As String
Dim rsRS As New Recordset
    
    cn.Execute ("UPDATE REQUISITIONSLIP_T SET cRefWRRNo = NULL WHERE cRefWRRNo = '" & Trim(TranNo) & "' AND cCompanyID = '" & COID & "'")
    
    GetChild
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        RefPONo = rsDetail!cRefNo
           
        'For REQUISITIONSLIP_T -------------------------------------------------------------------------------------------------------------------
        sSQL = "SELECT A.cTranNo, A.nIdentity, A.cItemNo " & _
                "FROM REQUISITIONSLIP_T A " & _
                "LEFT OUTER JOIN REQUISITION B ON A.cCompanyID = B.cCompanyID AND A.cTranNo = B.cRefNo " & _
                "LEFT OUTER JOIN REQUISITION_T C ON B.cPRNo = C.cPRNo AND A.cCompanyID = C.cCompanyID AND A.nIdentity = C.nRefIdentity " & _
                "LEFT OUTER JOIN PO_T D ON A.cCompanyID = D.cCompanyID AND B.cPRNo = D.cPRNo AND C.nIdentity = D.nPRIdentity " & _
                "WHERE B.cType = 'From RS' AND A.cStatus IN ('No Stock') " & _
                "AND D.cPONo = '" & Trim(RefPONo) & "' AND A.cCompanyID = '" & COID & "'"
                
        rsRS.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        Do Until rsRS.EOF
            cn.Execute "UPDATE REQUISITIONSLIP_T SET cRefWRRNo = '" & Trim(TranNo) & "' WHERE cTranNo = '" & Trim(rsRS!cTranNo) & "' AND " & _
                        "nIdentity = '" & rsRS!nIdentity & "' AND cItemNo = '" & Trim(rsRS!cItemNo) & "' AND cCompanyID = '" & COID & "'"
            rsRS.MoveNext
        Loop
        
        rsRS.Close
        '-------------------------------------------------------------------------------------------------------------------------------------------
        
        rsDetail.MoveNext
    Loop
    
    Set rsRS = Nothing

End Sub

Private Function AllowEdit() As Boolean
    AllowEdit = True
    
    'Cannot edit if transaction already has a collection reference
    If GetValueFrTable("cInvNo", "rfp_trade", "cInvNo = '" & Trim(rsHeader!cTranNo) & "'") <> "" Then
        MsgBox "Cannot edit Invoice with request for payment.", vbCritical + vbExclamation, msgTtl
        AllowEdit = False
        Exit Function
    ElseIf GetValueFrTable("cPINo", "ap_t", "cPINo = '" & Trim(rsHeader!cTranNo) & "'") <> "" Then
        MsgBox "Cannot edit Invoice with adjustment.", vbCritical + vbExclamation, msgTtl
        AllowEdit = False
        Exit Function
    ElseIf GetValueFrTable("cPINo", "voucher_trade", "cPINo = '" & Trim(rsHeader!cTranNo) & "'") <> "" Then
        MsgBox "Cannot edit Invoice with request for payment.", vbCritical + vbExclamation, msgTtl
        AllowEdit = False
        Exit Function
    End If
    
End Function

Private Function AllowDelete(sAction As String) As Boolean
    AllowDelete = True
    
    'Cannot delete if transaction already has a collection reference
    If GetValueFrTable("cInvNo", "rfp_trade", "cInvNo = '" & Trim(rsHeader!cTranNo) & "'") <> "" Then
        MsgBox "Cannot " & sAction & " Invoice with request for payment.", vbCritical + vbExclamation, msgTtl
        AllowDelete = False
        Exit Function
    ElseIf GetValueFrTable("cPINo", "ap_t", "cPINo = '" & Trim(rsHeader!cTranNo) & "'") <> "" Then
        MsgBox "Cannot " & sAction & " Invoice with adjustment.", vbCritical + vbExclamation, msgTtl
        AllowDelete = False
        Exit Function
    ElseIf GetValueFrTable("cPINo", "voucher_trade", "cPINo = '" & Trim(rsHeader!cTranNo) & "'") <> "" Then
        MsgBox "Cannot " & sAction & " Invoice with request for payment.", vbCritical + vbExclamation, msgTtl
        AllowDelete = False
        Exit Function
    End If
    
End Function


